<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>UUID生成器</title>
    <style>
        /* 页面整体样式 */
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f7f6;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            color: #333;
        }

        .container {
            text-align: center;
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            width: 80%;
            max-width: 500px;
        }

        h1 {
            font-size: 24px;
            color: #4CAF50;
            margin-bottom: 20px;
        }

        .uuid {
            font-size: 18px;
            color: #555;
            word-wrap: break-word;
            margin-top: 20px;
            padding: 10px;
            background-color: #f9f9f9;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        button {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 15px 30px;
            font-size: 16px;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        button:hover {
            background-color: #45a049;
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>UUID 生成器</h1>
        <button id="generateBtn">生成 UUID</button>
        <div class="uuid" id="uuidDisplay">点击按钮生成UUID</div>
    </div>

    <script>
        // UUID生成器
        const UUIDGeneratorBrowser = () =>
            ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
                (
                    c ^
                    (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
                ).toString(16)
            );

        // 获取按钮和显示UUID的容器
        const generateBtn = document.getElementById("generateBtn");
        const uuidDisplay = document.getElementById("uuidDisplay");

        // 按钮点击事件
        generateBtn.addEventListener("click", () => {
            const newUUID = UUIDGeneratorBrowser();
            uuidDisplay.textContent = newUUID;
        });
    </script>
</body>

</html>